<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>商城后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/layui_ext/dtree/dtree.css}" >
    <link rel="stylesheet" th:href="@{/lib/layui_ext/dtree/font/dtreefont.css}" >
    <style>
        body {
            background-color: #ffffff;
        }
        .layui-table-cell {
            height: auto !important;
            white-space: normal;
        }
    </style>


</head>
<body>

<span th:replace="common_page::common"></span>

<div class="layuimini-container" style="height:100%">
    <div class="layui-form layuimini-form">
        <input type="hidden" name="id" id="id" th:value="${model.id}">
        <input type="hidden" name="id" id="approveStatus" th:value="${model.approveStatus}">
        <input type="hidden" id="productDescriptionJson" th:value="${model.shopProductApproveDescriptionJson}" />

        <div class="layuimini-main" >
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">商品信息</li>
                    <li>商品介绍</li>
                    <li>商品预览</li>
                    <li>支付信息</li>
                    <li>物流信息</li>
                    <li>商品规格</li>
                </ul>

                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form-item" >
                            <label class="layui-form-label " >审核状态</label>
                            <div class="layui-input-block" style="padding-top: 9px;">
                                    <a th:if="${model.approveStatus==1}" >审核中</a>
                                    <a th:if="${model.approveStatus==2}" style="color:green">审核通过</a>
                                    <a th:if="${model.approveStatus==3}" style="color:red">审核驳回</a>
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >上架时间</label>
                                <div class="layui-input-block "  style="padding-top:7px;" >
                                    <a th:if="${model.shelvesStatus!=null&&model.shelvesStatus eq 1}">放入仓库</a>
                                    <a th:if="${model.shelvesStatus!=null&&model.shelvesStatus eq 2}">直接上架</a>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <label class="layui-form-label " >店铺商品ID</label>
                            <div class="layui-input-block">
                                <input type="text"  th:value="${model.id}"  class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">商品主图</label>
                            <div class="layui-input-block">
                                <img th:src="${model.httpMainPhotoFilePath}" th:width="450" th:height="450">
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >商品名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.name}"  class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline" style="width:40%">

                                <label class="layui-form-label " >分类名称</label>
                                <div class="layui-input-block">
                                    <input type="hidden" id="categoryId" th:value="${model.categoryId}" />
                                    <input type="text"  th:value="${model.categoryName}"  class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item" >
                            <label class="layui-form-label " >分类路径</label>
                            <div class="layui-input-block" >
                                <input type="text"  id="categoryPath" th:value="${model.categoryPath}"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label "  >品牌中文名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.brandChineseName}"  class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >品牌英文名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.brandEnglishName}"  class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" >

                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >店铺内分类路径</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.shopCategoryPath}"  class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >店铺内分类名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.shopCategoryName}"  class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >店铺ID</label>
                                <div class="layui-input-block">
                                    <input type="text"  id="shopId" th:value="${model.shopId}"  class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >店铺名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  th:value="${model.shopName}"  class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <label class="layui-form-label " >商家编码</label>
                            <div class="layui-input-block">
                                <input type="text"  th:value="${model.sellerNo}"  class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                        <div id="productDescription" style="width:750px;"></div>
                    </div>

                    <div class="layui-tab-item">


                        <div class="layui-form-item">
                            <label class="layui-form-label">商品预览</label>
                            <div class="layui-input-block">
                                <div class="layui-carousel" id="productPhotos">
                                    <div carousel-item>
                                        <div th:each="httpPreviewPhotoPath : ${model.httpPreviewPhotoPaths}" th:if="${model.httpPreviewPhotoPaths!=null}">
                                            <img th:src="${httpPreviewPhotoPath}" th:width="450" th:height="450" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>



                        <div class="layui-form-item">
                            <label class="layui-form-label">SKU预览</label>
                            <div class="layui-input-block">
                                <div class="layui-carousel" id="productSkuPhotos">
                                    <div carousel-item>
                                        <div th:each="httpSkuPreviewPhotoPath : ${model.httpSkuPreviewPhotoPaths}" th:if="${model.httpSkuPreviewPhotoPaths!=null}">
                                            <img th:src="${httpSkuPreviewPhotoPath}" th:width="450" th:height="450" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">

                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >付款方式</label>
                                <div class="layui-input-block " th:if="${model.payMethod!=null&&model.payMethod eq 1}">
                                    <input type="text"  value="一口价(普通交易模式)"  class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >库存计数</label>
                                <div class="layui-input-block " th:if="${model.buckleInventoryMethod!=null&&model.buckleInventoryMethod eq 1}">
                                    <input type="text"  value="买家拍下减库存"  class="layui-input">
                                </div>
                                <div class="layui-input-block " th:if="${model.buckleInventoryMethod!=null&&model.buckleInventoryMethod eq 2}">
                                    <input type="text"  value="买家付款减库存"  class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >售后服务</label>
                                <div class="layui-input-block "  style="padding-top:7px;" >
                                    <a th:if="${model.giveInvoice!=null&&model.giveInvoice eq 1}">提供发票</a>
                                    <a th:if="${model.changeOrReturn!=null&&model.changeOrReturn eq 1}">退换货承诺</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">

                        <div class="layui-form-item" >
                            <div class="layui-inline" style="width:40%">
                                <label class="layui-form-label " >提取方式</label>
                                <div class="layui-input-block "  style="padding-top:7px;" >
                                    <a th:if="${model.etractMethod!=null&&#strings.contains(model.etractMethod,'1')}">使用物流配送</a>
                                </div>
                            </div>
                            <div class="layui-inline" style="width:40%">

                            </div>
                        </div>

                        <div class="layui-form-item" >

                            <div class="layui-inline" style="width:80%">
                                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                    <legend>运费模板</legend>
                                </fieldset>
                                <div class="layui-form layuimini-form">
                                    <input type="hidden" id="freightTemplateId"  th:value="${model.freightTemplateId}" />
                                    <div class="layui-form-item">
                                        <div class="layui-inline" style="width:40%">

                                            <label class="layui-form-label ">模板名称:</label>
                                            <div class="layui-input-block "  id="freightTemplateName" style="padding-top:7px;" >
                                                加载中...
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="width:40%">
                                            <label class="layui-form-label ">发货地:</label>
                                            <div class="layui-input-block " id="deliverPath"  style="padding-top:7px;" >
                                                加载中...
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline" style="width:40%">
                                            <label class="layui-form-label ">是否包邮:</label>
                                            <div class="layui-input-block " id="freightStatusName"  style="padding-top:7px;" >
                                                加载中...
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="width:40%">
                                            <label class="layui-form-label ">计价方式:</label>
                                            <div class="layui-input-block " id="valuationMethodName"  style="padding-top:7px;" >
                                                加载中...
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item" id="transportModelPanel" style="display: none">
                                        <div class="layui-inline">
                                            <label class="layui-form-label ">运送方式:</label>
                                            <div class="layui-input-block "  id="expressTablePanel" style="padding-top:7px;display:none" >
                                                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                    <legend>快递</legend>
                                                </fieldset>
                                                <div class="layui-form layuimini-form">

                                                    <div class="layui-form-item">
                                                        <div class="layui-inline" >
                                                            <label class="layui-form-label "> 默认运费:</label>
                                                            <div class="layui-input-block "   style="padding-top:7px;" >
                                                            <a id="expressDefaultWeight"></a><a class="freightTemplateDefaultUnit"></a>内<a id="expressDefaultWeightMoney"></a>元&nbsp;&nbsp;
                                                            每增加<a id="expressDefaultAppendWeight"></a><a class="freightTemplateDefaultUnit"></a>,增加运费<a id="expressDefaultAppendWeightMoney"></a>元
                                                            </div>
                                                        </div>
                                                        <div class="layui-inline" style="width:100%">
                                                            <table class="layui-hide" id="freightTemplateExpressTable" ></table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-input-block " id="emsTablePanel"  style="padding-top:7px;display:none" >
                                                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                    <legend>EMS</legend>
                                                </fieldset>
                                                <div class="layui-form layuimini-form">

                                                    <div class="layui-form-item">
                                                        <div class="layui-inline" >
                                                            <label class="layui-form-label "> 默认运费:</label>
                                                            <div class="layui-input-block "   style="padding-top:7px;" >
                                                                <a id="emsDefaultWeight"></a><a class="freightTemplateDefaultUnit"></a>内<a id="emsDefaultWeightMoney"></a>元&nbsp;&nbsp;
                                                                每增加<a id="emsDefaultAppendWeight"></a><a class="freightTemplateDefaultUnit"></a>,增加运费<a id="emsDefaultAppendWeightMoney"></a>元

                                                            </div>
                                                        </div>
                                                        <div class="layui-inline" style="width:100%" >
                                                            <table class="layui-hide" id="freightTemplateEmsTable" ></table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="layui-input-block "  id="ordinaryMailTablePanel" style="padding-top:7px;display:none" >
                                                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                    <legend>平邮</legend>
                                                </fieldset>
                                                <div class="layui-form layuimini-form">

                                                    <div class="layui-form-item">
                                                        <div class="layui-inline" >
                                                            <label class="layui-form-label "> 默认运费:</label>
                                                            <div class="layui-input-block "   style="padding-top:7px;" >
                                                                <a id="ordinaryMailDefaultWeight"></a><a class="freightTemplateDefaultUnit"></a>内<a id="ordinaryMailDefaultWeightMoney"></a>元&nbsp;&nbsp;
                                                                每增加<a id="ordinaryMailDefaultAppendWeight"></a><a class="freightTemplateDefaultUnit"></a>,增加运费<a id="ordinaryMailDefaultAppendWeightMoney"></a>元

                                                            </div>
                                                        </div>
                                                        <div class="layui-inline" style="width:100%" >
                                                            <table class="layui-hide" id="freightTemplateOrdinaryMailTable" ></table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">

                        <table class="layui-hide" id="productSkuTable" ></table>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item" id="connectProduct" >
            <label class="layui-form-label required " >关联平台商品</label>
            <div class="layui-input-block">
                <input type="text" id="selectSpu"  lay-verify="required"  readonly required class="layui-input">
                <input type="hidden" id="productId" name="productId">
                <input type="hidden" id="productUuid" name="productUuid">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" id="approveBtns">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="passBtn">审核通过</button>
                <button class="layui-btn layui-btn-danger"  id="rejectBtn">审核驳回</button>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form','element', 'table','carousel'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            expressTable = layui.table,
            emsTable = layui.table,
            ordinaryMailTable = layui.table,
            element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        var carousel = layui.carousel;
        var carouselsku = layui.carousel;
        var index;
        var productRejectLoadding;
        var productPassLoadding;

        var productApproveId = $("#id").val();
        var approveStatus = $("#approveStatus").val();
        var productDescriptionJson = $("#productDescriptionJson").val();
        var productDescriptionObject = JSON.parse(productDescriptionJson);

        var templateId=$("#freightTemplateId").val();

        if(approveStatus!=1)
        {
            $("#approveBtns").hide();
            $("#connectProduct").hide();
        }
        if(productDescriptionObject!=null&&productDescriptionObject.productDescriptionImgs!=null&&productDescriptionObject.productDescriptionImgs.length>0)
        {
            var productDescriptionHtml="";
            for(var i=0;i<productDescriptionObject.productDescriptionImgs.length;i++)
            {
                var productDescriptionImg = productDescriptionObject.productDescriptionImgs[i];
                if(productDescriptionImg!=null)
                {
                    var imgHtml = "";
                    if(productDescriptionImg.link!=null)
                    {
                        imgHtml="<p><a href='"+productDescriptionImg.link+"'><img src='"+productDescriptionImg.httpFilePath+"' style='"+productDescriptionImg.width+productDescriptionImg.widthUnit+";'></a></p>";
                    }else{
                        imgHtml="<p><img src='"+productDescriptionImg.httpFilePath+"' style='"+productDescriptionImg.width+productDescriptionImg.widthUnit+";'></p>";
                    }
                    productDescriptionHtml+=imgHtml;
                }
            }
            $("#productDescription").html(productDescriptionHtml);
        }

        //建造实例化
        carousel.render({
            elem: '#productPhotos',
            width: '450px', //设置背景容器的宽度
            height: '450px', //设置背景容器的高度
            arrow: 'always', //始终显示箭头,不会消失
            //anim: 'updown' //切换动画方式:anim
            //indicator:'outside',
            indicator: 'outside'	//这个属性：小圆点在外面
        });


        //建造实例化
        carouselsku.render({
            elem: '#productSkuPhotos',
            width: '450px', //设置背景容器的宽度
            height: '450px', //设置背景容器的高度
            arrow: 'always', //始终显示箭头,不会消失
            //anim: 'updown' //切换动画方式:anim
            //indicator:'outside',
            indicator: 'outside'	//这个属性：小圆点在外面
        });



        /**
         * 设置品牌
         * @param brandId
         * @param brandName
         */
        function setSpu(spuId,spuUuid,spuName)
        {
            $("#productId").val(spuId);
            $("#productUuid").val(spuUuid);
            $("#selectSpu").val(spuName);
        }


        $("#selectSpu").click(function(){
            var categoryId = $("#categoryId").val();
            var categoryPath = $("#categoryPath").val();
            var index = layer.open({
                title: categoryPath + '——平台商品列表 ',
                type: 2,
                shade: 0.2,
                maxmin:true,
                btn: ["<i class='layui-icon layui-icon-ok'></i>确定", "关闭" ],
                yes: function (index) {
                    var spuObject = window["layui-layer-iframe" + index].getSelectSpu();
                    setSpu(spuObject.spuId,spuObject.spuUuid,spuObject.spuName);
                    layer.close(index);
                },
                area: ['80%', '80%'],
                content: '[[@{/}]]product/shopProductApprove/spuListPage/'+categoryId,
                zIndex: layer.zIndex,
                success: function(layero){
                    layer.setTop(layero);
                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

        });

        //监听提交
        form.on('submit(passBtn)', function (data) {

            var id = $("#id").val();
            var productId = $("#productId").val();
            var productUuid = $("#productUuid").val();

            productPassLoadding = layer.load();
            $.ajax({
                url:"[[@{/product/shopProductApprove/pass}]]",
                contentType: "application/json; charset=utf-8",
                type:'POST',
                data:JSON.stringify({id:id,productId:productId,productUuid:productUuid}),
                success:function(data){
                    if(data.code==0) {
                        layer.msg(data.msg);
                        return false;
                    }
                    var index = layer.alert(data.msg, {
                        title: '提示信息'
                    }, function () {
                        // 关闭弹出层
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.location.reload();
                        parent.layer.close(iframeIndex);

                    });
                },
                complete:function()
                {
                    layer.close(productPassLoadding);
                }
            });
            return false;
        });



        $("#rejectBtn").click(function() {
            index = layer.open({
                title: '审核驳回',
                type: 1,
                shade: 0.2,
                maxmin:true,

                area: ['45%', '50%'],
                btn: ['确定'],
                content: " <textarea  id=\"rejectText\" placeholder=\"请输入驳回原因\" class=\"layui-textarea\" lay-verify=\"required\" maxlength=\"200\"  style=\"width: 80%;height:80%;margin-top: 2%;margin-left: 2%;\" ></textarea>",
                yes: function(index, layero){
                    productRejectLoadding = layer.load();
                    var rejectText = $("#rejectText").val();
                    var approveId = $("#id").val();
                    var shopId = $("#shopId").val();
                    if(rejectText==null||rejectText==""||(rejectText.replace(/\s*/g,""))=="")
                    {
                        layer.msg("请输入驳回原因");
                        layer.close(productRejectLoadding);
                        return;
                    }

                    $.ajax({
                        url: "[[@{/}]]product/shopProductApprove/reject",
                        contentType: "application/json; charset=utf-8",
                        type: 'POST',
                        data: JSON.stringify({approveText:rejectText,approveId: approveId, shopId: shopId}),
                        success: function (data) {
                            if (data.code == 0) {
                                layer.msg(data.msg);
                                return false;
                            }
                            layer.close(index);

                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(iframeIndex);
                        },
                        complete:function()
                        {
                            layer.close(productRejectLoadding);
                        }
                    });
                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
        });


        table.render({
            elem: '#productSkuTable',
            url: "[[@{/}]]product/shopProductApprove/query/product/sku/list",
            method:'POST',
            where:{productApproveId:productApproveId},
            done:function(res, curr, count)
            {
            },
            cols: [
                [
                    {field: 'id',  title: '主键', width: 150},
                    {field: 'name', width: 600, title: '名称'},
                    {field: 'price', width: 150, title: '单价'},
                    {field: 'attributes', width: 150, title: '属性'},
                    {field: 'stockNum', width: 150, title: '库存数量'},
                    {field: 'httpMainPhoto', width: 150, title: '预览图',
                        templet: function (row) {
                            if(row.httpMainPhoto!=null) {
                                return "<a href='" + row.httpMainPhoto + "' target='_blank'><img src='" + row.httpMainPhoto + "' width='100' height='100'  /></a>";
                            }
                            return "";
                        }},
                    {field: 'roughWeight', width: 150, title: '毛重(单位kg)'},
                    {field: 'suttle', width: 150, title: '净重(单位kg)'},
                    {field: 'httpDescriptionImgPath', width: 150, title: '介绍图片',
                        templet: function (row) {
                            if(row.httpDescriptionImgPath!=null) {
                                return "<a href='" + row.httpDescriptionImgPath + "' target='_blank'><img src='" + row.httpDescriptionImgPath + "' width='100' height='100'  /></a>";
                            }
                            return "";
                        }}
                ]
            ],
            limits: [15,30,100,200],
            limit: 15,
            page: true,
            skin: 'line'
        });




        //渲染运费模板
        function loadFreightTemplate() {
            $.ajax({
                url: "[[@{/freightTemplate/detail}]]",
                contentType: "application/json; charset=utf-8",
                type: 'POST',
                data: JSON.stringify({id: templateId}),
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg);
                        return false;
                    }

                    var obj = data.data;
                    $("#freightTemplateName").html(obj.name);

                    var deliverPath="";
                    if(obj.deliverProvinceName!=null&&obj.deliverProvinceName!="")
                    {
                        deliverPath+=obj.deliverProvinceName;
                    }
                    if(obj.deliverCityName!=null&&obj.deliverCityName!="")
                    {
                        deliverPath+="/"+obj.deliverCityName;
                    }
                    if(obj.deliverAreaName!=null&&obj.deliverAreaName!="")
                    {
                        deliverPath+="/"+obj.deliverAreaName;
                    }
                    $("#deliverPath").html(deliverPath);


                    var freightTemplateTableColumnUnit="";
                    if(obj.valuationMethod==1)
                    {
                        $("#valuationMethodName").html("按件数");
                        freightTemplateTableColumnUnit="件数(件)";
                    }else if(obj.transportModel==2)
                    {
                        $("#valuationMethodName").html("按重量");
                        freightTemplateTableColumnUnit="重量(kg)";
                    }

                    if(obj.freightStatus==1)
                    {
                        $("#freightStatusName").html("自定义运费");
                        $("#transportModelPanel").show();
                        if(obj.expressDefaultRule!=null)
                        {
                            $("#expressTablePanel").show();
                            $("#expressDefaultWeight").html(obj.expressDefaultRule.defaultWeight);
                            $("#expressDefaultWeightMoney").html(obj.expressDefaultRule.defaultWeightMoney);
                            $("#expressDefaultAppendWeight").html(obj.expressDefaultRule.defaultAppendWeight);
                            $("#expressDefaultAppendWeightMoney").html(obj.expressDefaultRule.defaultAppendWeightMoney);

                            expressTable.render({
                                elem: '#freightTemplateExpressTable',
                                method:'POST',
                                cols: [
                                    [
                                        {field: 'selectAreas', width:400, title: '运送到'},
                                        {field: 'firstWeight', width:100, title: '首'+freightTemplateTableColumnUnit},
                                        {field: 'firstWeightMoney',width:100,  title: '首费(元)'},
                                        {field: 'appendWeight', width:100,title: '续'+freightTemplateTableColumnUnit},
                                        {field: 'appendWeightMoney', width:100,title: '续费(元)'}
                                    ]
                                ],
                                data: obj.expressAreaRules,
                                skin: 'line'
                            });
                        }

                        if(obj.emsDefaultRule!=null)
                        {
                            $("#emsTablePanel").show();
                            $("#emsDefaultWeight").html(obj.emsDefaultRule.defaultWeight);
                            $("#emsDefaultWeightMoney").html(obj.emsDefaultRule.defaultWeightMoney);
                            $("#emsDefaultAppendWeight").html(obj.emsDefaultRule.defaultAppendWeight);
                            $("#emsDefaultAppendWeightMoney").html(obj.emsDefaultRule.defaultAppendWeightMoney);

                            emsTable.render({
                                elem: '#freightTemplateEmsTable',
                                method:'POST',
                                cols: [
                                    [
                                        {field: 'selectAreas', width:400, title: '运送到'},
                                        {field: 'firstWeight', width:100, title: '首'+freightTemplateTableColumnUnit},
                                        {field: 'firstWeightMoney',width:100,  title: '首费(元)'},
                                        {field: 'appendWeight', width:100,title: '续'+freightTemplateTableColumnUnit},
                                        {field: 'appendWeightMoney', width:100,title: '续费(元)'}
                                    ]
                                ],
                                data: obj.emsAreaRules,
                                skin: 'line'
                            });
                        }

                        if(obj.ordinaryMailDefaultRule!=null)
                        {
                            $("#ordinaryMailTablePanel").show();
                            $("#ordinaryMailDefaultWeight").html(obj.ordinaryMailDefaultRule.defaultWeight);
                            $("#ordinaryMailDefaultWeightMoney").html(obj.ordinaryMailDefaultRule.defaultWeightMoney);
                            $("#ordinaryMailDefaultAppendWeight").html(obj.ordinaryMailDefaultRule.defaultAppendWeight);
                            $("#ordinaryMailDefaultAppendWeightMoney").html(obj.ordinaryMailDefaultRule.defaultAppendWeightMoney);

                            ordinaryMailTable.render({
                                elem: '#freightTemplateOrdinaryMailTable',
                                method:'POST',
                                cols: [
                                    [
                                        {field: 'selectAreas', width:400, title: '运送到'},
                                        {field: 'firstWeight', width:100, title: '首'+freightTemplateTableColumnUnit},
                                        {field: 'firstWeightMoney',width:100,  title: '首费(元)'},
                                        {field: 'appendWeight', width:100,title: '续'+freightTemplateTableColumnUnit},
                                        {field: 'appendWeightMoney', width:100,title: '续费(元)'}
                                    ]
                                ],
                                data: obj.ordinaryMailAreaRules,
                                skin: 'line'
                            });
                        }

                    }else{
                        $("#freightStatusName").html("包邮");
                    }


                    if(obj.valuationMethod==1)
                    {
                        $(".freightTemplateDefaultUnit").html("件");
                    }else{
                        $(".freightTemplateDefaultUnit").html("kg");
                    }

                },
                complete: function () {
                }
            });
        }

        loadFreightTemplate();





        
    });
</script>
</body>
</html>